#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m;
int a[N][N];
void solve() {
  cin >> n;
  rep(i, 0, n - 1) {
    for (int j = 0, k = i; k >= 0; j++, k--) a[j][k] = i;
  }
  rep(i, 1, n - 2) {
    for (int j = i + 1, k = n - 2; j <= n - 2; j++, k--) a[j][k] = i;
  }
  rep(i, 1, n - 2) {
    int x = a[i][i];
    a[i][i] = 0;
    a[i][n - 1] = a[n - 1][i] = x;
  }
  rep(i, 0, n - 1) rep(j, 0, n - 1) cout << a[i][j] << " \n"[j == n - 1];
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}